<?php
/*
 * [JINYUN!] (C)2001-2099 Jinyunweb.com
 * This is NOT a freeware, use is subject to license terms
 * $Id: 2017-12-13 03:39:35 apple $
*/
/*
	积分、余额日志
*/
defined('BY_JYA') or exit('error');
global $_RQ,$_AR;
$_RQ['op']=$_RQ['op']?$_RQ['op']:'list';
$return=array();
if($_RQ['op']=='list'){
	$pindex = max(1, intval($_RQ['page']));
	$psize = 10;
	$params=array('uniacid'=>$_SESSION['uniacid']);
	$return['params']=array();
	//会员ID
	if(!empty($_RQ['type'])){
		$params['type']=intval($_RQ['type']);
		$return['params']['type']=$_RQ['type'];
	}
	//时间范围
	if($_RQ['createtime']){
		$time_range=cfc('tools')->base64_decode($_RQ['createtime'],$_SESSION['base_key_str']);
		$time_range=json_decode($time_range,true);
		$return['params']['createtime']=$time_range;
		$params['createtime between']=array($time_range['tstart'],$time_range['tend']);
	}
	$list=pdo_getslice('jy_baojfee_feelog',$params,array($pindex,$psize),$total,array(),'','id desc');
	$return['list']=$list?$list:array();
	$totalpage=ceil($total/$psize);
	$totalpage=intval($totalpage);
	$return['totalpage'] =$totalpage;
	$return['params']['page'] =$pindex;
	$return['htmls']=array(
		'type'=>'list',
		'tabs'=>array(
			array('op'=>'list','title'=>'每日分红'),
		),
		'list'=>array('data'=>'list','tip'=>'每天结算昨天的级别分红+贡献值分红！<red>注意：可分红额不足的，将不能获得分红</red>','edit'=>false,'list'=>array(
			array('name'=>'orderprice','title'=>'营业额','type'=>'string'),
            array('name'=>'level_id','title'=>'等级','type'=>'select','options'=>'levels'),
			array('name'=>'jifee','title'=>'总分润','type'=>'string'),
			array('name'=>'onefee','title'=>'每人获得','type'=>'string'),
			array('name'=>'num','title'=>'人数','type'=>'string'),
			array('name'=>'type','title'=>'类型','type'=>'radio','options'=>'feelog_type'),
			array('name'=>'createtime','title'=>'创建时间','type'=>'time'),
		)),
		'search'=>array(
			array('name'=>'type','width'=>18,'title'=>'类型','type'=>'radio','options'=>'feelog_type'),
			array('type'=>'time_range','width'=>18,'title'=>'创建时间','name'=>'createtime','help'=>''),
		),
	);
    $levels=$this->getall('level',array('uniacid'=>$_SESSION['uniacid']),array('id','title','red_rate'),'id');
    $levels['0']=array('id'=>0,'title'=>'默认等级');
    $return['levels']=$levels;
	$return['feelog_type']=$this->feelog_type;
	exi($return);
}
if($_RQ['op'] == 'del'){
	$id=intval($_RQ['id']);
	if($id){
		pdo_delete('jy_baojfee_feelog',array('id'=>$id,'uniacid'=>$_SESSION['uniacid']));
	}
	$del=trim($_RQ['del'],';');
	if($del){
		$del=explode(';',$del);
		foreach($del as $id){
			$id=intval($id);
			if($id){
				pdo_delete('jy_baojfee_feelog',array('id'=>$id,'uniacid'=>$_SESSION['uniacid']));
			}
		}
	}
	exi('删除成功！');
}